package com.wephone.Student.ui;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import com.wephone.Student.R;

public class AskForFanli1Activity extends BaseActivity {
	private EditText fanliEdit1;
	private EditText fanliEdit2;
	private EditText fanliEdit3;
	private EditText fanliEdit4;

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		if(resultCode==11){
			finish();
		}
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_ask_for_fanli_1);
		
		init();
	}
	
	private void init(){
		fanliEdit1 = (EditText)findViewById(R.id.fanli_edit_1);
		fanliEdit2 = (EditText)findViewById(R.id.fanli_edit_2);
		fanliEdit3 = (EditText)findViewById(R.id.fanli_edit_3);
		fanliEdit4 = (EditText)findViewById(R.id.fanli_edit_4);
		
		findViewById(R.id.btn_back).setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				finish();
			}
		});
		findViewById(R.id.btn_finish).setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if(TextUtils.isEmpty(fanliEdit1.getText().toString())){
					Toast.makeText(getApplicationContext(), "国家必须填写", Toast.LENGTH_SHORT).show();
				}else if(TextUtils.isEmpty(fanliEdit2.getText().toString())){
					Toast.makeText(getApplicationContext(), "城市必须填写", Toast.LENGTH_SHORT).show();
				}else if(TextUtils.isEmpty(fanliEdit3.getText().toString())){
					Toast.makeText(getApplicationContext(), "学校必须填写", Toast.LENGTH_SHORT).show();
				}else if(TextUtils.isEmpty(fanliEdit4.getText().toString())){
					Toast.makeText(getApplicationContext(), "备选学校必须填写", Toast.LENGTH_SHORT).show();
				}else{
					Bundle bundle = new Bundle();
					bundle.putString("fanli_edit_1", fanliEdit1.getText().toString());
					bundle.putString("fanli_edit_2", fanliEdit2.getText().toString());
					bundle.putString("fanli_edit_3", fanliEdit3.getText().toString());
					bundle.putString("fanli_edit_4", fanliEdit4.getText().toString());
					startActivityForResult(new Intent(getApplicationContext(),AskForFanli2Activity.class).putExtras(bundle),1);
				}
			}
		});
	}
	

}
